package com.lhf.util;

public class PageVo {
    private Integer pageIndex;//当前页
    private Integer pageSize;//每页大小
    private Integer offset;//从第几条开始查


    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
        initParamter();
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getOffset() {
        return offset;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }


    private void initParamter() {
        if (pageIndex == null) {
            pageIndex = 1;
        }
        if (pageIndex < 1) {
            pageIndex = 1;
        }
        if (this.pageSize == null) {
            this.pageSize = 10;
        }
        if (this.pageSize == 0) {
            this.pageSize = 10;
        }

        final int startIndex = (this.pageIndex - 1) * this.pageSize;
        setOffset(startIndex);
    }


}
